package com.okaixz.client.controller;


import com.okaixz.client.model.domain.PwdInfo;
import com.okaixz.client.model.domain.PwdTagInfo;
import com.okaixz.client.model.dto.PwdSaveAllParams;
import com.okaixz.client.service.IPwdInfoService;
import com.okaixz.common.client.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cdz
 * @since 2025-09-17
 */
@RestController
@RequestMapping("/kb/pwd")
public class PwdInfoController {

    @Autowired
    private IPwdInfoService pwdInfoService;

    @RequestMapping("/save")
    public Result<PwdInfo> save(@RequestBody PwdInfo pwdInfo) {
        PwdInfo data=pwdInfoService.addPwdInfo(pwdInfo);
        return Result.success(data);
    }


    @RequestMapping("/uploadAll")
    public Result<List<PwdInfo>> uploadAll(@RequestBody List<PwdInfo> pwdInfoList) {
        List<PwdInfo> data=pwdInfoService.uploadAll(pwdInfoList);
        return Result.success(data);
    }
    /**
     * 批量删除
     */
    @RequestMapping("/deleteAll")
    public Result<Boolean> deleteAll(@RequestBody List<Long> ids) {
        Boolean data=pwdInfoService.deleteAll(ids);
        return Result.success(data);
    }
    @RequestMapping("/downloadAll")
    public Result<PwdSaveAllParams> downloadAll() {
        PwdSaveAllParams data=pwdInfoService.downloadAll();
        return Result.success(data);
    }

    @RequestMapping("/deleteTag")
    public Result<Boolean> deleteTag(@RequestBody PwdTagInfo pwdTagInfo){
        Boolean result=pwdInfoService.deleteTag(pwdTagInfo);
        return Result.success(result);
    }


}
